/** 商品功能模块 */
export const goodModuleMixin = {
	data() {
		return {
			bannerList: [],
			goodData: {},
			goodLoading: true,
			addressInfo: { address_id: "" }, // 地址信息
			comment_list: [], // 评价列表
			spec_list: [],
			sku_list: [],
		}
	},
	methods: {
		async getgoodFn() {
			this.goodLoading = true;
			try {
				const res = await this.$post('6544dfdcbc480', { goods_id: this.id });
				var _info = res.data || {}
				this.goodData = _info;
				this.bannerList = this.goodData.images || [];
				this.addressInfo = this.goodData.address_info || {};
				this.spec_list = this.goodData.goods_spec || [];
				this.sku_list = this.goodData.goods_sku || [];
				this.comment_list = (_info.comment_list || []).map(item => {
					return {
						...item,
						create_time: (item.create_time || "").slice(0, 10),
					}
				});
				if (this.goodData.data_type == 3) this.fd2_1_c2_c1 = this.goodData.presale_end_time - parseInt(Date.now() / 1000);

				if (!this.buyGoodStock) this.buyGoodStock = this.goodData.stock;
				if (!this.buyGoodPrice) this.buyGoodPrice = this.goodData.shop_price;
				if (!this.marketPrice) this.marketPrice = this.goodData.original_price;
				if (!this.buyGoodImg) this.buyGoodImg = this.goodData.thumb;

				this.$nextTick(() => { this.$refs.benben_tabsfd0_0.observeContent() })
			} catch (e) {}
			this.goodLoading = false;
		},
	}
};